package me.like.diandian;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.multidex.MultiDexApplication;

import com.scwang.smartrefresh.header.MaterialHeader;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreater;
import com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreater;
import com.scwang.smartrefresh.layout.api.RefreshFooter;
import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;

import me.like.diandian.view.MyClassicsFooter;

//import com.umeng.analytics.MobclickAgent;

/**
 * Created by shousakai on 2019/6/20.
 */

public class BaseApplication1 extends MultiDexApplication {
    private static BaseApplication1 instance;
    public static IWXAPI api;
    public static final String WX_APP_ID = "wx8e2e831a3a08e936";
    private void initRefeshLayout() {
        //设置全局的Header构建器
        SmartRefreshLayout.setDefaultRefreshHeaderCreater(new DefaultRefreshHeaderCreater() {
            @NonNull
            @Override
            public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
                return new MaterialHeader(context).setShowBezierWave(false);
            }
        });
        //设置全局的Footer构建器
        SmartRefreshLayout.setDefaultRefreshFooterCreater(new DefaultRefreshFooterCreater() {
            @NonNull
            @Override
            public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
                return new MyClassicsFooter(context, "已经到底啦~")
                        .setSpinnerStyle(SpinnerStyle.Translate)
                        .setPrimaryColorId(R.color.common_bg)
                        .setProgressResource(R.drawable.ic_progress_puzzle);
            }
        });

    }



    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        initRefeshLayout();
        UMConfigure.init(instance, "5d0c50724ca3575438000321"
                , null, UMConfigure.DEVICE_TYPE_PHONE, "");
        MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.MANUAL);
        api = WXAPIFactory.createWXAPI(instance, WX_APP_ID,true);
        api.registerApp(WX_APP_ID);
    }



    public static BaseApplication1 getInstance() {
        return instance;
    }
}
